﻿//*** Guidance generated code ***//
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Xml.Linq;

using ProjectBase.Core;

namespace ProjectBase.Core.Dao
{
    /// <summary>
    ///     This session (simple one) can be used for testing
    /// </summary>
    public sealed class SimpleSessionStorage : INHRequestSession, IDbRequestSession, IXmlRequestSession
    {
        #region IDbRequestSession Members
        IDbCommand IDbRequestSession.Command { get; set; }
        bool IDbRequestSession.OpenTransaction { get; set; }
        #endregion

        #region INHRequestSession Members

        IDictionary<string, object> _sessions = new SortedList<string, object>();
        object INHRequestSession.GetSession(string name)
        {
            object session;
            _sessions.TryGetValue(name, out session);
            return session;
        }
        void INHRequestSession.SetSession(string name, object session)
        {
            if (session.IsNull())
            {
                _sessions.Remove(name);
                return;
            }
            _sessions[name] = session;
        }
        #endregion

        #region IXmlRequestSession Members
        IDictionary<string, XDocument> IXmlRequestSession.XDocuments { get; set; }
        bool IXmlRequestSession.IsTransaction { get; set; }
        #endregion
    }
}